#!/usr/bin/env bash

function dc_test_main(){
    if [ $# = 0 ]; then
        echo -e "
    Usage:dc-test imgName [...options]
    "
        return 1
    fi

    imgName=$1
    containerName=${imgName/:/-/}
    containerName=${containerName/\//}
    echo "——>" $containerName
    if [ $# = 1 ]; then
        docker run --rm --name ${containerName}"-test" \
            $imgName
    else
        args=($*)
        docker run --rm --name ${containerName}"-test" \
            ${args[@]:1} \
            $imgName
    fi
}

dc_test_main $*